home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_13_05
/
allison
/
date.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-12
|
696b
|
29 lines
LISTING 2 - Implementation for the Date type
/* date.c */
#include <stdio.h>
#include "date.h"
static const char *month_text[] =
{"Bad month", "January", "February", "March", "April",
"May", "June", "July", "August", "September", "October",
"November", "December"};
char *date_format(const Date *dp, char *buf)
{
sprintf(buf,"%s %d, %d",
month_text[dp->month],dp->day,dp->year);
return buf;
}
int date_compare(const Date *dp1, const Date *dp2)
{
int result = dp1->year - dp2->year;
if (result == 0)
result = dp1->month - dp2->month;
if (result == 0)
result = dp1->day - dp2->day;
return result;
}